<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>JSON-LD idlharness test</title>
<link rel="author" title="W3C" href="http://www.w3.org/" />
<link rel="help" href="http://www.w3.org/TR/json-ld-api/#jsonldprocessor" />
<link rel="help" href="https://json-ld.org/spec/latest/json-ld-api/#loaddocumentcallback" />
<link rel="help" href="https://json-ld.org/spec/latest/json-ld-api/#remotedocument" />
<link rel="help" href="https://json-ld.org/spec/latest/json-ld-api/#jsonldoptions" />
<link rel="help" href="https://json-ld.org/spec/latest/json-ld-api/#jsonlderror" />
<link rel="help" href="https://json-ld.org/spec/latest/json-ld-api/#jsonlderrorcode" />
<script src="../../playground/Promise.js"></script>
<script src="../../playground/jsonld.js"></script>
<script src="http://w3c-test.org/resources/testharness.js"></script>
<script src="http://w3c-test.org/resources/testharnessreport.js"></script>
<script src="http://w3c-test.org/resources/WebIDLParser.js"></script>
<script src="http://w3c-test.org/resources/idlharness.js"></script>
</head>
<body>
<h1>idlharness test</h1>
<p>This test validates the WebIDL included in the JSON-LD 1.0 Processing Algorithms and API specification.</p>

<pre id="untested_idl" style="display:none">

</pre>

<pre id="idl">
[Constructor]
interface JsonLdProcessor {
    Promise compact (any input, JsonLdContext context, optional JsonLdOptions options);
    Promise expand (any input, optional JsonLdOptions options);
    Promise flatten (any input, optional JsonLdContext? context, optional JsonLdOptions options);
};

typedef (object or DOMString or (object or DOMString[])) JsonLdContext;

dictionary JsonLdOptions {
    DOMString              base;
    boolean                compactArrays = true;
    LoadDocumentCallback   documentLoader = null;
    (object? or DOMString) expandContext = null;
    DOMString              processingMode = "json-ld-1.1";
};

callback LoadDocumentCallback = Promise (DOMString url);

dictionary RemoteDocument {
    DOMString contextUrl = null;
    DOMString documentUrl;
    any document;
};

dictionary JsonLdError {
    JsonLdErrorCode code;
    DOMString?      message = null;
};

enum JsonLdErrorCode {
    "loading document failed",
    "list of lists",
    "invalid @index value",
    "conflicting indexes",
    "invalid @id value",
    "invalid local context",
    "multiple context link headers",
    "loading remote context failed",
    "invalid remote context",
    "recursive context inclusion",
    "invalid base IRI",
    "invalid vocab mapping",
    "invalid default language",
    "keyword redefinition",
    "invalid term definition",
    "invalid reverse property",
    "invalid IRI mapping",
    "cyclic IRI mapping",
    "invalid keyword alias",
    "invalid type mapping",
    "invalid language mapping",
    "colliding keywords",
    "invalid container mapping",
    "invalid type value",
    "invalid value object",
    "invalid value object value",
    "invalid language-tagged string",
    "invalid language-tagged value",
    "invalid typed value",
    "invalid set or list object",
    "invalid language map value",
    "compaction to list of lists",
    "invalid reverse property map",
    "invalid @reverse value",
    "invalid reverse property value"
};
</pre>

<script>

(function() {
  // Ensure that stringification tests are passed
  var toString = Object.prototype.toString;
  Object.prototype.toString = function() {
    if (this === window.JsonLdProcessor.prototype) {
      return '[object JsonLdProcessorPrototype]';
    } else if (this.constructor === window.JsonLdProcessor) {
      return '[object JsonLdProcessor]';
    }

    return toString.apply(this, arguments);
  }

  window.processor = new JsonLdProcessor();

  var idl_array = new IdlArray();

  //idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
  idl_array.add_idls(document.getElementById('idl').textContent);
  idl_array.add_objects( { JsonLdProcessor: [ 'window.processor' ]});

  idl_array.test();
})();

</script>

<div id="log"></div>

</body>
</html>

